package com.exam.microsoft;

/**
 * date:
 * description:
 */
public class Solution002 {
    public static void main(String[] args) {
        int[] nums = {10, 3, 4, 7};
        Solution002 instance = new Solution002();
        int res = instance.solution(nums, 2, 3);
        System.out.println(res);
    }

    public int solution(int[] A, int X, int Y) {
        int res = Integer.MAX_VALUE;
        int N = A.length;
        int span = (X - 1) * Y;
        for (int i = 0; i < N - span; i++) {
            int sum = 0;
            for (int j = 0; j < X; j++) {
                sum += A[i + j * Y];
            }
            res = Math.min(res, sum);
        }
        return res;
        // write your code in Java 8 (Java SE 8)
    }
}
